/*
package com.yinNuo.collectWool.Task;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yinNuo.collectWool.collectWoolHttp.JiuZhangHeadlinesHttps;
import com.yinNuo.collectWool.core.constant.Costant;
import com.yinNuo.collectWool.mobileApi.entity.UserDoTask;
import com.yinNuo.collectWool.mobileApi.service.UserDoTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

*/
/**
 * @author: yinNuo
 * create at: 2021/11/28 下午5:59
 * @description: 定时任务
 *//*

@Component
@EnableScheduling
@Slf4j
public class JiuZhangHeadlinesScheduledTask {
    @Autowired
    private JiuZhangHeadlinesHttps jiuZhangHeadlinesHttps;

    */
/*@Autowired
    private User user;*//*


    @Resource
    private UserDoTaskService userDoTaskService;

    */
/**
     * 新手任务
     *//*

    @Scheduled(cron = "0 0 0 * * ?")
    public void readArticles() {
        //获取所有数据  =======>[UserDoTask{id=1, userId=6, woolTaskId=1, woolTaskDetailId=1, token='123123'}]
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 1) {
                //获取主页信息，如果新手任务没有做则做新手任务
                Map<String, Object> map1 = jiuZhangHeadlinesHttps.forwardContent(userDoTask.getToken());
                String newcomerReading = map1.get("newcomerReading").toString();//新人首次阅读任务
                if (!"已完成".equals(newcomerReading)) {//未完成
                    //执行首次阅读
                    List<String> readArticlesResponse = jiuZhangHeadlinesHttps.getReadArticlesResponse();
                    //读5篇文章 五分钟
                    for (int i = 0; i < readArticlesResponse.size(); i++) {
                        Map<String, Object> map = jiuZhangHeadlinesHttps.readArticle(readArticlesResponse.get(i), userDoTask.getToken());
                        log.info("新手任务读取文章赚金币结果:{}",map);
                        try {
                            Thread.sleep(Costant.SLEEP_TIME_MINUTE);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
                String perfectData = map1.get("perfectData").toString();//完善资料任务
                if (!"已完成".equals(perfectData)) {//未完成
                    // todo 完善相关资料
                }
            }

        }


    }

    // 日常任务

    */
/**
     * 读文章任务  todo 暂时测试每30秒第一次文章,每六分钟跑一次
     *//*

    @Scheduled(cron = "0 0/1 * * * ? ")//目前每半小时执行一次
    public void usual() {

        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 2) {
                //阅读文章
                //获取文章列表
                List<String> readArticlesResponse = jiuZhangHeadlinesHttps.getReadArticlesResponse();
                for (int i = 0; i < readArticlesResponse.size(); i++) {
                    //读文章
                    Map<String, Object> map1 = jiuZhangHeadlinesHttps.iphoneReadArticle(userDoTask.getToken(), readArticlesResponse.get(i));
                    //获取金币
                    Map<String, Object> map = jiuZhangHeadlinesHttps.readArticle(readArticlesResponse.get(i), userDoTask.getToken());
                    //读取文章失败则直接读下篇文章 不停留线程
                    if (!"500".equals(map.get("code").toString())) {
                        try {
                            //三十秒走一次
                            Thread.sleep(Costant.SLEEP_TIME_MINUTE);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    log.info("文章读取结果:{}",map1);
                    log.info("读取文章获取金币结果:{}",map);
                }
            }

        }

    }

    */
/**
     * 签到任务 目前都有分享三次文章，和下面转发分享不是同一个，调用同一个接口，区别转发文章是带文章id分享，这个没带文章id分享
     * todo 这里任务具体内容根据 获取签到列表 signInList() 里的具体内容而定
     *//*

    @Scheduled(cron = "0 0 0 * * ?")
    public void sign() {
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 3) {
                //先获取今日签到所需要做的任务
                List<Map<String, Object>> maps = jiuZhangHeadlinesHttps.signInList(userDoTask.getToken());
                List<Map<String, Object>> collect = maps.stream().filter(item -> {
                    if (item.containsKey("target")) {
                        item.get("target");
                        return true;
                    }
                    return false;
                }).collect(Collectors.toList());
                collect.forEach(item -> {
                    //获取任务名
                    String title = item.get("title").toString();
                    //该任务一共需要完成几次
                    Integer target = Integer.valueOf(item.get("target").toString());
                    //该任务当前已经完成几次
                    Integer has = Integer.valueOf(item.get("has").toString());
                    if (title.contains("分享")) {
                        //是分享任务，执行分享操作
                        for (Integer i = 0; i < target; i++) {
                            jiuZhangHeadlinesHttps.signIn(userDoTask.getToken());
                        }
                    }
                    if (title.contains("视频")) {
                        //是视频任务，执行看视频操作  todo 这里安卓抓不到，用的苹果手机抓的 但是不知道是否和苹果签到一样，切换成安卓的后又签到成功了
                        jiuZhangHeadlinesHttps.topAds(userDoTask.getToken(), "71");//苹果端四个看视频任务里最上面的签到后再看视频获取的金币
                        jiuZhangHeadlinesHttps.topAds(userDoTask.getToken(), "94");//苹果端任务签到后再看视频获取的金币
                        for (Integer i = 0; i < target; i++) {
//                    httpUtils.topAds(user.getToken(),"94");
                        }
                    }
                });

                //todo  可能还有其他任务需要做。

                // todo 任务都做完再执行点击签到功能 未开发

            }

        }

    }

    */
/**
     * 转发文章 5次
     *//*

    @Scheduled(cron = "0 0 0 * * ?")
    public void forwardContent() {
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 4) {
                //阅读文章
                //获取文章列表
                List<String> readArticlesResponse = jiuZhangHeadlinesHttps.getReadArticlesResponse();
                for (int i = 0; i < readArticlesResponse.size(); i++) {
                    //转发文章
                    Map<String, Object> map = jiuZhangHeadlinesHttps.forwardContent(readArticlesResponse.get(i), userDoTask.getToken());
                    log.info("转发文章结果:{}:", map);
                    try {
                        Thread.sleep(Costant.SLEEP_TIME_MINUTE_TWO);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }

        }

    }

    */
/**
     * 四个看视频任务
     * todo 目前测试视频冷却时间间隔是半小时
     *//*

    @Scheduled(cron = "0 0/10 * * * ? ")//每半小时执行一次
    public void topAds() {
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 5) {
                //todo 这里待优化传过来的四个id 应该是 的任务列表里的 需要判断暂时写死值
                Map<String, Object> map = jiuZhangHeadlinesHttps.forwardContent(userDoTask.getToken());
                try {
                    Map<String, Object> map1 = jiuZhangHeadlinesHttps.topAds(userDoTask.getToken(), map.get("adsTask0").toString());
                    Thread.sleep(Costant.SLEEP_TIME_MINUTE);
                    Map<String, Object> map2 = jiuZhangHeadlinesHttps.topAds(userDoTask.getToken(), map.get("adsTask1").toString());
                    Thread.sleep(Costant.SLEEP_TIME_MINUTE);
                    Map<String, Object> map3 = jiuZhangHeadlinesHttps.topAds(userDoTask.getToken(), map.get("adsTask2").toString());
                    Thread.sleep(Costant.SLEEP_TIME_MINUTE);
                    Map<String, Object> map4 = jiuZhangHeadlinesHttps.topAds(userDoTask.getToken(), map.get("adsTask3").toString());
                    Thread.sleep(Costant.SLEEP_TIME_MINUTE);
                    System.out.println("第一个视频：" + map1 + "第二个视频：" + map2 + "第三个视频：" + map3 + "第四个视频：" + map4);
                    log.info("第一个视频结果:{},第二个视频结果:{},第三个视频结果:{},第四个视频结果:{}", map1, map2, map3 , map4);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }

    }

    */
/**
     * 最顶部单独一个的看视频任务 限时福利
     * 调试显示冷却一个半小时 这里半小时调用一次
     *//*

    @Scheduled(cron = "0 0/10 * * * ? ")//每半小时执行一次
    public void extraAds() {
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 6) {
                //看视频前先点击限时福利
                Map<String, Object> map = jiuZhangHeadlinesHttps.extraAds(userDoTask.getToken());
                //然后再看视频 看视频接口和四个看视频接口相同，不过视频id不同罢了
                Map<String, Object> map1 = jiuZhangHeadlinesHttps.topAds(userDoTask.getToken(), "98");
                log.info("限时福利：打卡结果:{},视频打卡{}", map, map1);
            }

        }

    }


    //  以下是苹果端赚金币任务

    */
/**
     * 苹果左上角签到任务
     *//*

    @Scheduled(cron = "0 0/10 * * * ? ")//每半小时执行一次
    public void iphoneLeftTopSign() {
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 7) {
                Map<String, Object> map = jiuZhangHeadlinesHttps.iphoneLeftTopSign(userDoTask.getToken());
                log.info("苹果左上角签到任务结果:{}",map);
                try {
                    //签到后30秒再执行签到看视频任务
                    Thread.sleep(Costant.SLEEP_TIME_SECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //苹果端最左上角签到后再看视频获取的金币
                Map<String, Object> map1 = jiuZhangHeadlinesHttps.topAds(userDoTask.getToken(), "77");
                log.info("苹果左上角签到后看视频任务执行结果:{}", map1);
            }

        }

    }

    */
/**
     * 苹果右上角签到后看视频任务
     *//*

    @Scheduled(cron = "0 0/10 * * * ? ")//每半小时执行一次
    public void iphoneLeftTopSignAds() {
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 8) {
                Map<String, Object> map = jiuZhangHeadlinesHttps.iphoneRightTopSignAds(userDoTask.getToken());
                log.info("苹果右上角签到后看视频任务执行结果:{}", map);
            }

        }

    }

    */
/**
     * 苹果任务栏里的签到
     *//*

    @Scheduled(cron = "0 0 0 * * ? ")//每天凌晨执行一次
    public void iphoneSign() {
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 9) {
                Map<String, Object> map = jiuZhangHeadlinesHttps.iphoneSign(userDoTask.getToken());
                log.info("苹果任务栏里的签到执行结果:{}", map);
            }

        }

    }

    */
/**
     * 提现任务
     *//*

    @Scheduled(cron = "0 0 10 * * ? ")//每天上午十点提现
    public void everyDayGetMoney() {
        List<UserDoTask> list = userDoTaskService.list(new QueryWrapper<UserDoTask>().eq("wool_task_id", Costant.JIUZHANG_ID));
        for (UserDoTask userDoTask : list) {
            if (userDoTask.getWoolTaskDetailId() == 10) {
                Map<String, Object> map = jiuZhangHeadlinesHttps.everyDayGetMoney(userDoTask.getToken());
                log.info("提现任务执行结果:{}", map);
            }

        }

    }


}
*/
